<%-- 
    Document   : ShowOrders
    Created on : Jul 30, 2012, 1:42:50 PM
    Author     : RasJLK
--%>

<%@page import="java.text.DateFormat"%>
<%@page import="ejb.Customer"%>
<%@page import="java.util.Iterator"%>
<%@page import="ejb.CustomerOrder"%>
<%@page import="java.util.List"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Order List</title>
        <link rel="stylesheet" type="text/css" href="style.css" media="screen" />
    </head>
    <body>
        
        <%
            List<CustomerOrder> styles = (List<CustomerOrder>) request.getAttribute("orders");
            Iterator it = styles.iterator();
         %>
         
         <table style="width:80%">
         <caption>Order List</caption>
             <tr>
                 <th></th>
                 <th>Order No</th>
                 <th>Customer Id</th>
                 <th>Customer Name</th>
                 <th>Amount</th>
                 <th>Due Date</th>
                 <th>Comments</th>
             </tr>
         <%
            while (it.hasNext()) {
                CustomerOrder order =(CustomerOrder) it.next();
                Customer cust = order.getCustomer();
               try{
                out.println("<tr>");
                out.println("<td><a href=\"UpdateOrder?id=" +order.getId() +"\">Update</a></td>");
                out.println("<td>" + order.getOrderNo() + "</td>");
                out.println("<td>" + cust.getId() + "</td>");
                out.println("<td>" + cust.getName() + "</td>");
                out.println("<td>" + order.getAmmount() + "</td>");
                out.println("<td>" +  DateFormat.getDateInstance(DateFormat.LONG).format( order.getDueDate() ) + "</td>");
                out.println("<td>" + order.getComments() + "</td>");
                out.println("</tr>");
                }catch(Exception es){}
            }
        %>
         </table>
         <br />
         <a href="UpdateOrder">Add new Order</a> 
         <a href="CustomerList">View Customers</a>
    </body>
</html>
